﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using EZCRS.HCMS.Entity;
using EZCRS.HCMS.Data;

namespace EZCRS.HCMS.SqlClient
{
    public class sql_hfg_module_help
    {
        private string sqlstr = "";


        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="page"></param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="pagecount">返回页数总数</param>
        /// <returns></returns>
        public List<hfg_module_help> getallbypage(int page, string strwhere,out int pagecount)
        {

            int recordcount = 0;
            pagecount = 1;
            List<hfg_module_help> _log = ExecSql.GetTableList<hfg_module_help>("hfg_module_help", "*", " scoredate desc ", "id", CFun.pagesize(), page, strwhere, out recordcount);
            pagecount = CFun.pagecount(recordcount);
            return _log;
        }


        /// <summary>
        /// 返回所有符合条件的信息
        /// </summary>
        /// <param name="strwhere">条件</param>
        /// <returns></returns>
        public List<hfg_module_help> getall(string strwhere)
        {
            if (strwhere != "")
                sqlstr = "select * from hfg_module_help where " + strwhere;
            else
                sqlstr = "select * from hfg_module_help ";
            try
            {
                return ExecSql.GetTableList<hfg_module_help>(sqlstr);
            }
            catch { return null; }
        }

        /// <summary>
        /// 返回一条信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public hfg_module_help getitem(int id)
        {
            try
            {
                return ExecSql.GetTableList<hfg_module_help>("select * from hfg_module_help where id=" + id.ToString() + "")[0];
            }
            catch { return null; }
        }

        #region 删除
        /// <summary>
        /// 删除一条信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool deleteitem(int id)
        {
            return (ExecSql.SqlExecNoquery("delete from hfg_module_help where id=" + id.ToString()) > 0) ? true : false;
        }

        /// <summary>
        /// 删除一批数据
        /// </summary>
        /// <param name="idlist"></param>
        /// <returns></returns>
        public bool deleteitem(string idlist)
        {
            return (ExecSql.SqlExecNoquery("delete from hfg_module_help where id in ("+idlist+")") > 0) ? true : false;
        }
        #endregion

        /// <summary>
        /// 新增或修改一条信息
        /// </summary>
        /// <param name="_hfg_module_help"></param>
        /// <returns></returns>
        public bool insertorupdate(hfg_module_help _hfg_module_help)
        {
            return ExecSql.InsertOrUpdateData<hfg_module_help>(_hfg_module_help);
        }


        public List<hfg_module_help> getall(string sqlwhere, string orderstr)
        {
            if (sqlwhere != "")
                sqlstr = "select * from hfg_module_help where " + sqlwhere;
            else
                sqlstr = "select * from hfg_module_help ";

            if (orderstr != "")
                sqlstr += " order by " + orderstr;
            try
            {
                return ExecSql.GetTableList<hfg_module_help>(sqlstr);
            }
            catch { return null; }
        }
    }
}
